package com.ruoyi.sl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sl.domain.SlRfworkCheck;
import com.ruoyi.sl.service.ISlRfworkCheckService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 待办复核人Controller
 * 
 * @author admin
 * @date 2024-06-26
 */
@RestController
@RequestMapping("/sl/checkr")
public class SlRfworkCheckController extends BaseController
{
    @Autowired
    private ISlRfworkCheckService slRfworkCheckService;

    /**
     * 查询待办复核人列表
     */
    @PreAuthorize("@ss.hasPermi('sl:checkr:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlRfworkCheck slRfworkCheck)
    {
        startPage();
        List<SlRfworkCheck> list = slRfworkCheckService.selectSlRfworkCheckList(slRfworkCheck);
        return getDataTable(list);
    }

    /**
     * 导出待办复核人列表
     */
    @PreAuthorize("@ss.hasPermi('sl:checkr:export')")
    @Log(title = "待办复核人", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlRfworkCheck slRfworkCheck)
    {
        List<SlRfworkCheck> list = slRfworkCheckService.selectSlRfworkCheckList(slRfworkCheck);
        ExcelUtil<SlRfworkCheck> util = new ExcelUtil<SlRfworkCheck>(SlRfworkCheck.class);
        util.exportExcel(response, list, "待办复核人数据");
    }

    /**
     * 获取待办复核人详细信息
     */
    @PreAuthorize("@ss.hasPermi('sl:checkr:query')")
    @GetMapping(value = "/{rfcheckId}")
    public AjaxResult getInfo(@PathVariable("rfcheckId") Long rfcheckId)
    {
        return success(slRfworkCheckService.selectSlRfworkCheckByRfcheckId(rfcheckId));
    }

    /**
     * 新增待办复核人
     */
    @PreAuthorize("@ss.hasPermi('sl:checkr:add')")
    @Log(title = "待办复核人", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlRfworkCheck slRfworkCheck)
    {
        return toAjax(slRfworkCheckService.insertSlRfworkCheck(slRfworkCheck));
    }

    /**
     * 修改待办复核人
     */
    @PreAuthorize("@ss.hasPermi('sl:checkr:edit')")
    @Log(title = "待办复核人", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlRfworkCheck slRfworkCheck)
    {
        return toAjax(slRfworkCheckService.updateSlRfworkCheck(slRfworkCheck));
    }

    /**
     * 删除待办复核人
     */
    @PreAuthorize("@ss.hasPermi('sl:checkr:remove')")
    @Log(title = "待办复核人", businessType = BusinessType.DELETE)
	@DeleteMapping("/{rfcheckIds}")
    public AjaxResult remove(@PathVariable Long[] rfcheckIds)
    {
        return toAjax(slRfworkCheckService.deleteSlRfworkCheckByRfcheckIds(rfcheckIds));
    }
}
